package com.hunliji.monitor.web.controller.cloud;

import com.hunliji.common.response.ResponseData;
import com.hunliji.monitor.share.component.redis.RedisFacade;
import com.hunliji.monitor.web.facade.AdvertiseConsumeFacade;
import com.hunliji.monitor.web.facade.DataSyncFacade;
import com.hunliji.monitor.web.facade.TestFacade;
import com.hunliji.monitor.web.model.vo.TestVO;
import com.xxl.job.core.biz.model.ReturnT;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xingfeng
 * @date 2018/11/26
 */
@Api(value = "测试控制器", tags = "测试cloud接口")
@RestController
@RequestMapping(value = "/cloudApi/test")
public class TestCloudController {

    @Resource
    private TestFacade testFacade;
    @Resource
    private RedisFacade redisFacade;
    @Resource
    private AdvertiseConsumeFacade advertiseConsumeFacade;

    @ApiOperation(value = "根据主键查询")
    @GetMapping(value = "/getById")
    public ResponseData<TestVO> getById(Long id) {
        return ResponseData.success(testFacade.getById(id));
    }

    @ApiOperation(value = "测试10分钟定时任务")
    @GetMapping(value = "/testTenJob")
    public ResponseData<Boolean> testTenJob() {
        advertiseConsumeFacade.logNearTenMinuteTodayAndYesterdayConsume();
        return ResponseData.success(true);
    }
    @Resource
    private DataSyncFacade dataSyncFacade;

    @PostMapping(value = "/dataSync")
    public ResponseData<Boolean> dataSync(@RequestParam("merchantIdList") List<Long> merchantIdList) {
        dataSyncFacade.syncBond(merchantIdList);
        return ResponseData.success(true);
    }

    @PostMapping(value = "/syncRecord")
    public ResponseData<Boolean> syncRecord() {
        dataSyncFacade.syncRecord();
        return ResponseData.success(true);
    }

    /**
     * 迁移检查
     * @return
     */
    @PostMapping(value = "/syncBondCheck")
    public ResponseData<Boolean> syncBondCheck() {
        dataSyncFacade.syncBondCheck();
        return ResponseData.success(true);
    }



}
